﻿<UserControl x:Class="ViewMaker.Core.Views.ViewLayoutView"

        xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"  
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:system="clr-namespace:System;assembly=mscorlib"
        xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
        xmlns:it="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
        Width="400">
    <Border BorderBrush="LightSteelBlue" BorderThickness="2" >
        <StackPanel Background="WhiteSmoke">
            <Grid Background="LightSteelBlue">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal" Grid.Column="0">
                    <Grid Margin="2,3,0,3">
                        <ComboBox Name="File" Foreground="Blue" FontSize="10" Width="42" SelectionChanged="File_SelectionChanged">
                            <ComboBoxItem Content="Show XAML"/>
                            <ComboBoxItem Content="Show Layout"/>
                            <ComboBoxItem Content="Close" />
                        </ComboBox>
                        <TextBlock Margin="5,2,2,2" IsHitTestVisible="False" Foreground="Gray">File</TextBlock>
                    </Grid>
                    <Button Command="{Binding Path=RefreshCommad}" Width="20" Height="20">
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/refresh.png" />
                    </Button>
                    <Button Command="{Binding Path=SaveLayoutCommand}" Width="20" Height="20" >
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/save.png" />
                    </Button>
                    <Button Command="{Binding Path=EditViewControlSettingsCommand}" Width="20" Height="20">
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/settings.png" />
                    </Button>
                    <Button Command="{Binding Path=UpCommand}" Width="20" Height="20">
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/up.png" />
                    </Button>
                    <Button Command="{Binding Path=DownCommand}" Width="20" Height="20">
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/down.png" />
                    </Button>
                    <Button Command="{Binding Path=LeftCommand}" Width="20" Height="20">
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/left.png" />
                    </Button>
                    <Button Command="{Binding Path=RightCommand}" Width="20" Height="20">
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/right.png" />
                    </Button>
                    <Button Command="{Binding Path=RemoveItemCommand}" Width="20" Height="20">
                        <Image Source="/SilverlightViewMaker.Core;Component/Images/remove.png" />
                    </Button>
                    <Grid Margin="2,3,0,3">
                        <ComboBox Name="AddControlListCombo"   Foreground="Blue" FontSize="10" ItemsSource="{Binding Path=CurrentItem.AddControlList}" Width="75" SelectionChanged="AddControlListCombo_SelectionChanged" />
                        <TextBlock Margin="5,2,2,2" IsHitTestVisible="False" FontSize="9" Foreground="Gray">Add Control</TextBlock>
                    </Grid>
                    <Grid Margin="2,3,0,3">
                        <ComboBox Name="AddItemListCombo"  Foreground="Blue" FontSize="10" ItemsSource="{Binding Path=CurrentItem.AddItemList}" Width="70" SelectionChanged="AddItemListCombo_SelectionChanged"  />
                        <TextBlock Margin="5,2,2,2" IsHitTestVisible="False" FontSize="9" Foreground="Gray">Add Item</TextBlock>
                    </Grid>

                </StackPanel>
                <Button Grid.Column="1" Command="{Binding Path=CloseCommand}" Width="24" Height="24">
                    <Image Source="/SilverlightViewMaker.Core;Component/Images/close.png" />
                </Button>
            </Grid>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="0" />
                    <RowDefinition Height="175" />
                    <RowDefinition Height="275" />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                </Grid.ColumnDefinitions>

                <sdk:TreeView Grid.Row="1" Name="treeView" ItemsSource="{Binding Path=Root}" 
                      SelectedItemChanged="treeView_SelectedItemChanged" KeyDown="treeView_KeyDown" Background="WhiteSmoke" BorderThickness="0" FontSize="10" Foreground="Black">
                    <sdk:TreeView.ItemTemplate>
                        <sdk:HierarchicalDataTemplate ItemsSource="{Binding Children}">
                            <TextBlock Text="{Binding Title}" MouseRightButtonDown="TreeViewItem_MouseRightButtonDown">
                        <it:ContextMenuService.ContextMenu>
                            <it:ContextMenu>
                                <it:MenuItem Command="{Binding Path=Owner.UpCommand}">
                                    <it:MenuItem.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/SilverlightViewMaker.Core;Component/Images/up.png" Height="16" Width="16" />
                                            <TextBlock>Up</TextBlock>
                                        </StackPanel>
                                    </it:MenuItem.Header>
                                </it:MenuItem>
                                <it:MenuItem Command="{Binding Path=Owner.DownCommand}">
                                    <it:MenuItem.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/SilverlightViewMaker.Core;Component/Images/down.png" Height="16" Width="16" />
                                            <TextBlock>Down</TextBlock>
                                        </StackPanel>
                                    </it:MenuItem.Header>                                    
                                </it:MenuItem>
                                <it:MenuItem Command="{Binding Path=Owner.LeftCommand}">
                                    <it:MenuItem.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/SilverlightViewMaker.Core;Component/Images/left.png" Height="16" Width="16" />
                                            <TextBlock>Left</TextBlock>
                                        </StackPanel>
                                    </it:MenuItem.Header>                                    
                                </it:MenuItem>
                                <it:MenuItem Command="{Binding Path=Owner.RightCommand}">
                                    <it:MenuItem.Header>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/SilverlightViewMaker.Core;Component/Images/right.png" Height="16" Width="16" />
                                            <TextBlock>Right</TextBlock>
                                        </StackPanel>
                                    </it:MenuItem.Header>                                    
                                </it:MenuItem>
                                <it:MenuItem Header="Remove" Command="{Binding Path=Owner.RemoveItemCommand}" />                               
                                <it:MenuItem Header="Insert Panel" Command="{Binding Path=Owner.InsertControlCommand}" />
                                <it:MenuItem Header="Show XAML" Command="{Binding Path=Owner.ShowCurrentXamlCommand}" />
                            </it:ContextMenu>
                        </it:ContextMenuService.ContextMenu>
                            </TextBlock>
                        </sdk:HierarchicalDataTemplate>
                    </sdk:TreeView.ItemTemplate>
                </sdk:TreeView>

                <ScrollViewer Grid.Column="0" Grid.Row="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" FontSize="10" Foreground="Black">
                    <StackPanel>
                        <toolkit:Expander IsExpanded="True" Header="Layout Item" >
                            <ContentControl  Name="propPanel" Content="{Binding Path=ItemContent, Mode=OneWay}" IsTabStop="False">
                            </ContentControl>
                        </toolkit:Expander>
                        <toolkit:Expander IsExpanded="True" Header="Layoyut Control">
                            <ContentControl  Name="editPanel" Content="{Binding Path=ControlContent, Mode=OneWay}" IsTabStop="False">
                            </ContentControl>
                        </toolkit:Expander>
                    </StackPanel>

                </ScrollViewer>
                <StackPanel Grid.Column="0" Grid.Row="3" Margin="3">
                    <TextBlock Name="cntlInfo" Height="20" Text="{Binding Path=InfoText}" FontSize="10" Foreground="Black" ></TextBlock>
                </StackPanel>
            </Grid>
        </StackPanel>
    </Border>
 
</UserControl>
